package com.pg.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.sy.EipPartialDischarges;
import com.pg.mapper.EipPartialDischargesMapper;
import com.pg.service.EipPartialDischargesService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 局部放电 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipPartialDischargesServiceImpl extends ServiceImpl<EipPartialDischargesMapper, EipPartialDischarges> implements EipPartialDischargesService {

    @Autowired
    private EipPartialDischargesMapper eipPartialDischargesMapper;

    @Override
    public IPage<EipPartialDischarges> selectForList(Page<EipPartialDischarges> page, EipPartialDischarges eipPartialDischarges, Date startCheckTime, Date endCheckTime) {
        LambdaQueryWrapper<EipPartialDischarges> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(eipPartialDischarges.getSupplierWorkNo())) {
            queryWrapper.like(EipPartialDischarges::getSupplierWorkNo, eipPartialDischarges.getSupplierWorkNo());
        }
        if (StringUtils.isNotEmpty(eipPartialDischarges.getCategoryType())) {
            queryWrapper.like(EipPartialDischarges::getCategoryType, eipPartialDischarges.getCategoryType());
        }
        if (StringUtils.isNotEmpty(eipPartialDischarges.getProductModel())) {
            queryWrapper.like(EipPartialDischarges::getProductModel, eipPartialDischarges.getProductModel());
        }
        if (StringUtils.isNotEmpty(eipPartialDischarges.getEquipmentName())) {
            queryWrapper.like(EipPartialDischarges::getEquipmentName, eipPartialDischarges.getEquipmentName());
        }
        if (StringUtils.isNotEmpty(eipPartialDischarges.getPdCode())) {
            queryWrapper.like(EipPartialDischarges::getPdCode, eipPartialDischarges.getPdCode());
        }
        if (startCheckTime != null) {
            queryWrapper.ge(EipPartialDischarges::getCheckTime, startCheckTime);
        }
        if (endCheckTime != null) {
            queryWrapper.le(EipPartialDischarges::getCheckTime, endCheckTime);
        }
        return eipPartialDischargesMapper.selectPage(page, queryWrapper);
    }

}
